#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ls (x << 1)
#define rs (x << 1 | 1)
using namespace std;

const int V = 1e6;
const int N = 1000010;

struct Tree {int mxl, mir, x;} t[N << 2];

struct Sort {
    bool operator () (int x, int y) { return x > y; }
};

int q, mxl[N], mir[N], dl[N], dr[N];
multiset<int> sl[N], sr[N];
priority_queue<int> Sl;
priority_queue<int, vector<int>, Sort> Sr;

void pushup(int x) {
    t[x].mxl = max(t[ls].mxl, t[rs].mxl);
    t[x].mir = min(t[ls].mir, t[rs].mir);
    t[x].x = min(min(t[ls].x, t[rs].x), t[rs].mir - t[ls].mxl);
}

void build(int x, int L, int R) {
    if (L == R) {
        t[x] = {mxl[L], mir[L], mir[L] - mxl[L]};
        return;
    }
    // cout << "qwq" << endl;
    int mid = L + R >> 1;
    build(ls, L, mid); build(rs, mid + 1, R);
    pushup(x);
}

void upd(int x, int L, int R, int l) {
    if (L == R) {
        t[x] = {mxl[L], mir[L], mir[L] - mxl[L]};
        // cout << "x = " << mir[L] - mxl[L] << endl;
        return;
    }
    int mid = L + R >> 1;
    if (l <= mid) upd(ls, L, mid, l);
    else upd(rs, mid + 1, R, l);
    pushup(x);
}

int main() {
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);
    // int st = clock();
    memset(mxl, 245, sizeof(mxl));
    memset(mir, -245, sizeof(mir));
    build(1, 1, V);
    // cout << "qwq" << endl;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++) {
        char opt = getchar();
        while (opt != 'R' && opt != 'A')
            opt = getchar();
        int l, r; scanf("%d%d", &l, &r);
        // cout << "qwq" << endl;
        if (opt == 'A') {
            Sl.push(l); Sr.push(r);
            sl[r].insert(l); sr[l].insert(r);
            mxl[r] = max(mxl[r], l);
            mir[l] = min(mir[l], r);
        } else {
            dl[l]++; dr[r]++;
            while (dl[Sl.top()]) dl[Sl.top()]--, Sl.pop();
            while (dr[Sr.top()]) dr[Sr.top()]--, Sr.pop();
            sl[r].erase(sl[r].find(l));
            sr[l].erase(sr[l].find(r));
            if (sl[r].size()) mxl[r] = *(--sl[r].end());
            else mxl[r] = -1e8;
            if (sr[l].size()) mir[l] = *sr[l].begin();
            else mir[l] = 1e8;
        }
        upd(1, 1, V, l); upd(1, 1, V, r);
        int L = Sl.top(), R = Sr.top();
        if (L < R) {
            printf("%d\n", mir[L] - mxl[R]);
        } else {
            // cout << "qwq " << L << " " << R << endl;
            printf("%d\n", t[1].x);
        }
    }
    // cout << "time = " << clock() - st << endl;
    return 0;
}
/*
5
A 1 5
A 2 7
A 4 6
A 6 8
R 4 6
*/